package com.developmentReformProject.enums;

/**
 * 请求处理枚举类
 * @author 胡志鹏
 * @date 2021-7-13
 */
public enum HttpStatusEnum {

    SUCCESS(0,"成功"),
    NOTFOUND(101,"没有找到满足条件的数据"),
    SERVER_ERROR(500,"服务器内部错误"),
    NO_LOGIN(600,"用户未登录"),
    ERR_USER(601,"非法用户"),
    ERR_PASSWORD(602,"密码错误"),
    ERR_VERIFY_CODE(603,"验证码错误"),
    ERR_BAD_REQUEST(400,"参数解析失败"),
    ERR_METHOD_NOT_ALLOWED(405,"不支持当前请求方法"),
    ERR_DATA_VALID_FAIL(416,"数据检验失败");

    private Integer value;

    private String description;


    private HttpStatusEnum(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public Integer getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 枚举值转换成描述
     * @param value
     * @return
     */
    public static String valueToDescription(int value){
        for(HttpStatusEnum httpStatusEnum:values()){
            if(httpStatusEnum.getValue()==value){
                return httpStatusEnum.getDescription();
            }
        }
        return null;
    }



}
